﻿@using System.Data;

<h3>DataTable</h3>

<Table DataSource="data">
    @foreach(DataColumn column in _dataTable.Columns)
    {
        <Column TData="object" Title="@column.ColumnName" DataIndex=@($"['{column.ColumnName}']")></Column>
    }
</Table>

@code {
    DataTable _dataTable = new DataTable();

    DataRow[] data => _dataTable?.AsEnumerable().ToArray();

    protected override void OnInitialized()
    {
        _dataTable.Columns.Add("Name");
        _dataTable.Columns.Add("Age");
        _dataTable.Columns.Add("Address");

        _dataTable.Rows.Add("John Brown", 32, "New York No. 1 Lake Park");
        _dataTable.Rows.Add("Jim Green", 42, "London No. 1 Lake Park");
        _dataTable.Rows.Add(null, 32, "Sidney No. 1 Lake Park");

        base.OnInitialized();
    }
}
